package com.mynews.activity;

import android.Manifest;
import android.content.Intent;

import com.mynews.R;
import com.mynews.base.BaseActivity;
import com.tbruyelle.rxpermissions.Permission;
import com.tbruyelle.rxpermissions.RxPermissions;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.functions.Action1;

/**
 * Created by Administrator on 2017/6/22.
 */

public class SplashActivity extends BaseActivity {
    @Override
    protected int setView() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initData() {
        Observable.timer(2, TimeUnit.SECONDS)
                .compose(RxPermissions.getInstance(this).ensureEach(Manifest.permission.CAMERA,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE))
                .subscribe(new Action1<Permission>() {
                    @Override
                    public void call(Permission permission) {
//                        if(permission.granted){
                            startActivity(new Intent(SplashActivity.this, MainActivity.class));
                            finish();
//                        }
                    }
                });
    }

}
